package com.ybkj.daijia.template.em;

import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.core.io.support.PropertiesLoaderUtils;

public class OtherServiceMethodTag implements TemplateMethodModelEx {

    @Override
    public Object exec(List arguments) throws TemplateModelException {

        Properties properties;
        boolean show = false;
        try {
            properties = PropertiesLoaderUtils.loadAllProperties("config.properties",
                OtherServiceMethodTag.class.getClassLoader());

            boolean zhuanche_show = BooleanUtils
                .toBoolean(properties.getProperty("function.zhuanche.open", "false"));

            boolean paotui_show = BooleanUtils
                .toBoolean(properties.getProperty("function.paotui.open", "false"));

            boolean freight_show = BooleanUtils
                .toBoolean(properties.getProperty("function.freight.open", "false"));

            if (zhuanche_show || paotui_show || freight_show) {
                show = true;
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

        return show;
    }

}
